var t = require;
var e = module;
var o = exports;
var _n15,
    i =
        (this && this.__extends) ||
        ((_n15 = function n(t, e) {
            return (_n15 =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) {
                        Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                    }
                })(t, e);
        }),
        function (t, e) {
            function o() {
                this.constructor = t;
            }
            _n15(t, e), (t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o()));
        });
Object.defineProperty(o, "__esModule", {value: !0});
var s = t("BaseSdk"),
    r = t("SDKEvent"),
    c = t("Common"),
    a = t("Global"),
    u = (function (t) {
        function e() {
            var e = (null !== t && t.apply(this, arguments)) || this;
            return (
                (e._recorderShareFunc = null),
                (e._musicPauseFunc = null),
                (e._musicPauseThis = null),
                (e._musicResumeFunc = null),
                (e._musicResumeThis = null),
                (e._clipboardData = ""),
                (e._playScreenTime = 0),
                (e._screenSpaceTime = 0),
                (e._interstitiaId = ""),
                (e._moreGameBtn = null),
                (e._recorder = null),
                (e._videoPath = ""),
                (e._recorderStatus = 0),
                (e._recorderEndTime = 0),
                (e._recorderTime = 0),
                (e._groupId = "ballUsers"),
                (e._videoId = "494255"),
                (e._bannerId = "bakof5ngp737nf5e92"),
                (e._screenId = "32j0xvji1d6e45gfqo"),
                (e._shareId = "7kfwckfor33pf7mmg8"),
                (e._shareTitle = "一起来粉碎球球吧"),
                (e._shareDesc = "粉碎球球"),
                (e._videoTopics = ["粉碎球球", "粉碎球球小游戏", "解压小游戏"]),
                (e._videoLoaded = !1),
                (e._videoOptions = null),
                (e._videoAd = null),
                (e._interstitiaAd = null),
                (e._bannerLoaded = !1),
                (e.lastAdTime = 0),
                (e.gridAd = null),
                (e.boxBannerAd = null),
                (e.boxPortalAd = null),
                (e.banner = null),
                (e.bannerCount = 0),
                (e.customAd = null),
                (e.customAdBig = null),
                (e.screenShow = !1),
                (e.lastshockTime = 0),
                (e.accChangeBack = null),
                (e.bannerShow = !1),
                (e.needNewBanner = !1),
                e
            );
        }
        return (
            i(e, t),
            (e.prototype.init = function () {
                (this.lastAdTime = new Date().getTime()),
                    qg.setLoadingProgress({progress: 0}),
                    qg.getSystemInfoSync().platformVersionCode >= 1076 &&
                        (qg.onReportMonitor(function (t) {
                            0 == t.code ? console.log(t) : console.error(t);
                        }),
                        qg.reportMonitor("load_res_begin"));
            }),
            (e.prototype.loadBanner = function (t) {
                var e = this;
                void 0 === t && (t = !1),
                    (this.banner = qg.createBannerAd({
                        posId: "73f62ba665fe43f8aa8cdd4546447465",
                        adIntervals: 40,
                        style: {}
                    })),
                    this.banner.onError(function (t) {
                        console.log("banner广告加载失败", t), (e.needNewBanner = !0);
                    }),
                    this.banner
                        .show()
                        .then(function () {
                            console.log("banner广告展示完成"), (e.bannerShow = !0), (e.needNewBanner = !1);
                        })
                        .catch(function (t) {
                            console.log("banner广告展示失败", JSON.stringify(t));
                        });
            }),
            (e.prototype.showBanner = function () {
                try {
                    this.needNewBanner
                        ? this.loadBanner(!0)
                        : this.banner && !this.bannerShow && ((this.bannerShow = !0), this.banner.show());
                } catch (t) {}
            }),
            (e.prototype.hideBanner = function () {
                try {
                    this.banner && this.bannerShow && ((this.bannerShow = !1), this.banner.hide());
                } catch (t) {}
            }),
            (e.prototype.setKeepScreenOn = function () {
                qg.setKeepScreenOn({
                    keepScreenOn: !0,
                    success: function success() {},
                    fail: function fail() {},
                    complete: function complete() {}
                });
            }),
            (e.prototype.login = function () {}),
            (e.prototype.getUserInfo = function (t) {
                var e = {nickName: "OPPO用户"};
                "" != a.default.userInfo.nickName && (e.nickName = a.default.userInfo.nickName), t.success(e, "OPPO");
            }),
            (e.prototype.createMoreGamesButton = function () {
                this._moreGameBtn;
            }),
            (e.prototype.startRecorder = function () {
                this._recorder &&
                    !this._isRecorder &&
                    ((this._recorderTime = new Date().getTime()),
                    (this._isRecorder = !0),
                    this._recorder.start({duration: 300}),
                    cc.systemEvent.emit(r.default.CHANGE_RECORDER_STATE));
            }),
            (e.prototype.stopRecorder = function (t) {
                this._recorder &&
                    this._isRecorder &&
                    ((this._recorderEndTime = new Date().getTime()),
                    (this._recorderShareFunc = t),
                    this._recorder.stop(),
                    (this._isRecorder = !1),
                    cc.systemEvent.emit(r.default.CHANGE_RECORDER_STATE));
            }),
            (e.prototype.getIsScreenRecordVideo = function () {
                return "" != this._videoPath && this._recorderEndTime - this._recorderTime > 8e3;
            }),
            (e.prototype.getRecorderState = function () {
                return this._isRecorder;
            }),
            (e.prototype.getRecorderTime = function () {
                return this._recorderEndTime - this._recorderTime;
            }),
            (e.prototype.getLastAdTime = function () {
                return this.lastAdTime;
            }),
            (e.prototype.shareRecorder = function () {
                this._videoPath && "" !== this._videoPath
                    ? this.sendEvent({key: "shareVideo"})
                    : this.showToast("正在生成录屏,请稍后!");
            }),
            (e.prototype.showRewardVideo = function (t) {
                var e = this;
                (e._videoOptions = t),
                    e._videoAd
                        ? this._videoAd
                              .show()
                              .then(function () {
                                  console.log("显示广告成功");
                              })
                              .catch(function (t) {
                                  console.log("显示广告错误", t),
                                      e._videoAd.load().then(function () {
                                          return e._videoAd.show();
                                      });
                              })
                        : ((this._videoAd = qg.createRewardedVideoAd({adUnitId: e._videoId})),
                          this._videoAd.onLoad(function () {
                              console.log("广告加载完成");
                          }),
                          this._videoAd.onError(function (t) {
                              (e._videoLoaded = !1),
                                  e.sendEvent({key: "videoError", value: {code: t.errCode}}),
                                  setTimeout(function () {
                                      e._videoAd.load().then(function () {
                                          e._videoLoaded = !0;
                                      });
                                  }, 3e4),
                                  console.log("视频加载失败", t.errCode);
                          }),
                          this._videoAd.onClose(function (t) {
                              (e._videoLoaded = !1),
                                  (e.lastAdTime = new Date().getTime()),
                                  t && t.isEnded
                                      ? (e._videoOptions && e._videoOptions.success && e._videoOptions.success(),
                                        e.sendEvent({key: "playVideoSuccess"}))
                                      : e.sendEvent({key: "playVideoFail"});
                          }),
                          this._videoAd.load().then(function () {
                              (e._videoLoaded = !0),
                                  e._videoAd
                                      .show()
                                      .then(function () {
                                          console.log("显示广告成功");
                                      })
                                      .catch(function (t) {
                                          console.log("显示广告错误", t),
                                              e._videoAd.load().then(function () {
                                                  return e._videoAd.show();
                                              });
                                      });
                          })),
                    e.sendEvent({key: "playVideo"});
            }),
            (e.prototype.setClipboardData = function (t) {
                qg.setClipboardData({
                    data: t.data,
                    success: function success() {},
                    fail: function fail() {},
                    complete: function complete() {}
                });
            }),
            (e.prototype.getVideoState = function () {
                return this._videoLoaded;
            }),
            (e.prototype.playScreen = function (t) {
                void 0 === t && (t = 1), (this.screenShow = !1), new Date().getTime(), this.lastAdTime;
            }),
            (e.prototype.sendEvent = function () {}),
            (e.prototype.vibrateShort = function () {
                var t = new Date().getTime();
                t - this.lastshockTime > 100 &&
                    c.default._shockOpen &&
                    ((this.lastshockTime = t),
                    qg.vibrateShort({
                        success: function success() {},
                        fail: function fail() {},
                        complete: function complete() {}
                    }));
            }),
            (e.prototype.vibrateLong = function () {
                c.default._shockOpen &&
                    qg.vibrateLong({
                        success: function success() {},
                        fail: function fail() {},
                        complete: function complete() {}
                    });
            }),
            (e.prototype.showToast = function (t) {
                qg.showToast({title: t, icon: "success", duration: 2e3});
            }),
            (e.prototype.showLoading = function (t) {
                qg.showLoading({title: t});
            }),
            (e.prototype.hideLoading = function () {
                qg.hideLoading({});
            }),
            (e.prototype.share = function () {}),
            (e.prototype.setLocalStorage = function (t, e) {
                cc.sys.localStorage.setItem(t, e);
            }),
            (e.prototype.getLocalStorage = function (t) {
                return cc.sys.localStorage.getItem(t);
            }),
            (e.prototype.contentSafe = function (t) {
                var e = {text: t.content};
                this.sendHttpRequest(
                    c.default.contentSafeTT,
                    e,
                    function (e) {
                        e.valid ? t.callBack(!0) : t.callBack(!1);
                    },
                    function () {
                        t.callBack(!1);
                    }
                );
            }),
            (e.prototype.registerAccChange = function (t) {
                var e = this;
                (this.accChangeBack = t),
                    qg.startAccelerometer({
                        success: function success(t) {
                            console.log("调用开始加速度成功", t.errMsg);
                        },
                        fail: function fail(t) {
                            console.log("调用开始加速度失败", t.errMsg);
                        }
                    }),
                    qg.onAccelerometerChange(function (t) {
                        e.accChangeBack(-t.y.toFixed(2), t.x.toFixed(2), t.z.toFixed(2), e);
                    });
            }),
            (e.prototype.unRegisterAccChange = function () {
                qg.stopAccelerometer({
                    success: function success(t) {
                        console.log("调用停止加速度成功", t.errMsg);
                    },
                    fail: function fail(t) {
                        console.log("调用停止加速度失败", t.errMsg);
                    }
                });
            }),
            (e.prototype.onShow = function () {}),
            (e.prototype.getLaunchOptionsSync = function () {
                return qg.getLaunchOptionsSync();
            }),
            (e.prototype.showCustomAd = function () {}),
            (e.prototype.hideCustomAd = function () {
                this.customAd && (this.customAd.hide(), this.customAd.destroy());
            }),
            (e.prototype.showCustomAdBig = function () {}),
            (e.prototype.hideCustomAdBig = function () {
                this.customAdBig && (this.customAdBig.hide(), this.customAdBig.destroy());
            }),
            (e.prototype.showGridAd = function () {
                var t = this;
                qg.getSystemInfoSync().platformVersionCode >= 1090
                    ? (null == this.boxPortalAd &&
                          ((this.boxPortalAd = qg.createGameDrawerAd({adUnitId: "494250", style: {top: 0}})),
                          this.boxPortalAd.onError(function (t) {
                              console.log("盒子九宫格广告加载失败", t);
                          }),
                          this.boxPortalAd.onClose(function () {
                              console.log("close"), t.boxPortalAd.isDestroyed || t.boxPortalAd.show();
                          })),
                      this.boxPortalAd.show().then(function () {
                          console.log("show success");
                      }))
                    : console.log("快应用平台版本号低于1090，暂不支持互推盒子相关 API");
            }),
            (e.prototype.hideGridAd = function () {
                this.boxPortalAd && this.boxPortalAd.hide();
            }),
            (e.prototype.showGridScorllAd = function () {}),
            (e.prototype.hideGridScorllAd = function () {
                this.boxBannerAd && this.boxBannerAd.hide();
            }),
            e
        );
    })(s.default);
o.default = u;
